package com.hoopeu.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.TextView;

import com.hoopeu.smarthome.R;

public class SingleChoiceAdapter extends ArrayAdapter<String>{

	private int mCheckedPosition;
	  private Context mContext;
	  private int mLayoutResId;

	  public SingleChoiceAdapter(Context paramContext, int paramInt1, String[] paramArrayOfString, int paramInt2)
	  {
	    super(paramContext, paramInt1, paramArrayOfString);
	    this.mContext = paramContext;
	    this.mLayoutResId = paramInt1;
	    this.mCheckedPosition = paramInt2;
	  }

	  public View getView(int paramInt, View paramView, ViewGroup paramViewGroup)
	  {
	    if (paramView == null)
	      paramView = ((LayoutInflater)this.mContext.getSystemService("layout_inflater")).inflate(this.mLayoutResId, null);
	    String str = (String)getItem(paramInt);
	    if (str != null)
	      ((TextView)paramView.findViewById(R.id.listitem1)).setText(str);
	    CheckBox localCheckBox = (CheckBox)paramView.findViewById(R.id.checkbox);
	    if (this.mCheckedPosition >= 0)
	    {
	      if (this.mCheckedPosition == paramInt)
	        localCheckBox.setBackgroundDrawable(this.mContext.getResources().getDrawable(R.drawable.ico_checked));
	    }
	    else
	      return paramView;
	    localCheckBox.setBackgroundDrawable(this.mContext.getResources().getDrawable(R.drawable.transparent));
	    return paramView;
	  }
}
